home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Reversed fades ƒ / Scissors fade reversed.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-12  |  3.2 KB  |  109 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Scissors fade reversed.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define CorrectTime 3
  32. #define theWindowWidth (boundsRect.right-boundsRect.left)
  33. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  34.  
  35. pascal short ScissorsFadeReversed(Rect boundsRect, Pattern *thePattern);
  36.  
  37. /* A region in two parts, starting at the middle of the bottom side and working
  38.    toward the bottom corners, then up the left and right sides. */
  39.    
  40. pascal short ScissorsFadeReversed(Rect boundsRect, Pattern *thePattern)
  41. {
  42.     RgnHandle    curregion, boundsRgn, sectrgn;
  43.     int            cx,gap,lastx,lasty;
  44.     int            BlockSize;
  45.     
  46.     BlockSize=theWindowHeight/25;
  47.     cx = theWindowWidth / 2;
  48.  
  49.     boundsRgn=NewRgn();
  50.     SetRectRgn(boundsRgn, boundsRect.left, boundsRect.top, boundsRect.right, boundsRect.bottom);
  51.     sectrgn=NewRgn();
  52.     curregion=NewRgn();
  53.     lastx=theWindowWidth/2;
  54.     gap=theWindowWidth/2+BlockSize;
  55.     do
  56.     {
  57.         StartTiming();
  58.         SetEmptyRgn(curregion);
  59.         MoveTo(cx,0);
  60.         OpenRgn();
  61.             LineTo(lastx,theWindowHeight);        /* get the right half on bottom side */
  62.             LineTo(gap,theWindowHeight);
  63.             LineTo(cx,0);
  64.             LineTo(theWindowWidth-lastx,theWindowHeight);    /* left 1/2 on bottom */
  65.             LineTo(theWindowWidth-gap,theWindowHeight);
  66.             LineTo(cx,0);
  67.         CloseRgn(curregion);
  68.         OffsetRgn(curregion, boundsRect.left, boundsRect.top);
  69.         SectRgn(curregion, boundsRgn, sectrgn);
  70.         FillRgn(sectrgn, *thePattern);
  71.         lastx=gap;
  72.         gap+=BlockSize;
  73.         TimeCorrection(CorrectTime);
  74.     }
  75.     while (gap<=theWindowWidth+BlockSize);
  76.     
  77.     gap=theWindowHeight-BlockSize;
  78.     lasty=theWindowHeight;
  79.     do
  80.     {
  81.         StartTiming();
  82.         SetEmptyRgn(curregion);
  83.         MoveTo(cx,0);
  84.         OpenRgn();
  85.             LineTo(theWindowWidth,lasty);   /* get the right half */
  86.             LineTo(theWindowWidth,gap);
  87.             LineTo(cx,0);
  88.             LineTo(0,lasty);                   /* get the left half */
  89.             LineTo(0,gap);
  90.             LineTo(cx,0);
  91.         CloseRgn(curregion);
  92.         OffsetRgn(curregion, boundsRect.left, boundsRect.top);
  93.         SectRgn(curregion, boundsRgn, sectrgn);
  94.         FillRgn(sectrgn, *thePattern);
  95.         lasty=gap;
  96.         gap-=BlockSize;
  97.         TimeCorrection(CorrectTime);
  98.     }
  99.     while (gap>=0);
  100.     
  101.     FillRect(&boundsRect, *thePattern);            /* in case we missed any bits */
  102.     
  103.     DisposeRgn(curregion);
  104.     DisposeRgn(boundsRgn);
  105.     DisposeRgn(sectrgn);
  106.     
  107.     return 0;
  108. }
  109.